package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description NursingLevelController
 * @Author lizhiwen
 * @Date 2024-09-10
 */
@RestController
@RequestMapping("nursingLevel")
public class NursingLevelController extends BaseController{

    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping("/listAll")
    public ResponseResult<List<NursingLevelVo>> findAll(){
        List<NursingLevelVo> list = nursingLevelService.findAll();


        return success(list);
    }

    @PostMapping("/insert")

    public ResponseResult insert(@RequestBody NursingLevelDto nursingLevelDto){

        nursingLevelService.insert(nursingLevelDto);

        return success();

    }

    @GetMapping("/listByPage")
    public ResponseResult<PageResponse<NursingLevelVo>> page(Integer pageNum, Integer pageSize, String name, Integer status){
        PageResponse<NursingLevelVo> page = nursingLevelService.page(pageNum, pageSize, name, status);

        return success(page);
    }

    @GetMapping("/{id}")
    public ResponseResult<NursingLevelVo> findById(@PathVariable Integer id){
        NursingLevelVo nursingLevelVo = nursingLevelService.findById(id);

        return success(nursingLevelVo);
    }

    @PutMapping("/update")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.update(nursingLevelDto);

        return success();

    }

    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteById(@PathVariable Integer id){
        nursingLevelService.deleteById(id);


        return success();
    }

    @PutMapping("/{id}/status/{status}")
    public ResponseResult setStatus(@PathVariable Integer id, @PathVariable Integer status){

        nursingLevelService.setStatus(id, status);

        return success();

    }


}
